package com.tt.jshb.advice;

import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzecool.common.utils.ToastUtils;
import com.hzecool.core.base.TBaseActivity;
import com.tt.jshb.R;

import butterknife.BindView;

/**
 * Created by tu on 2018/7/30.
 */

public class AdviceActivity extends TBaseActivity<IAdviceView, AdvicePresenter>
        implements IAdviceView {
    @BindView(R.id.et)
    EditText et;
    @BindView(R.id.tv)
    TextView tv;

    @Override
    public void onLoadData(Object o) {
        ToastUtils.showShortToast("反馈成功");
        finish();
    }

    @Override
    public void onEmptyData() {

    }

    @Override
    public void onLoadError(String msg) {
        showAlertDlg("提示", msg);
    }

    @Override
    public void onNetError(String msg) {

    }

    @Override
    public int getLayoutID() {
        return R.layout.advice_layout;
    }

    @Override
    public void initView() {
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (TextUtils.isEmpty(et.getText().toString().trim())) {
                    showAlertDlg("提示", "请填写意见");
                } else {
                    mPresenter.uploadAdvice(et.getText().toString().trim());
                }
            }
        });
    }

    @Override
    public void initTitle(ImageView ivBack, TextView tvBack, View llBack, TextView titleName, TextView tvMenu, View titleRoot) {
        titleName.setText("意见反馈");
    }

    @Override
    protected AdvicePresenter createPresenter() {
        return new AdvicePresenter();
    }
}
